namespace AutoClub.Core.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class LookupValues : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.RaceStates",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(),
                        Active = c.Boolean(nullable: false),
                        CreatedBy = c.String(nullable: false),
                        CreatedOn = c.DateTimeOffset(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.CarCategories",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(),
                        Active = c.Boolean(nullable: false),
                        CreatedBy = c.String(nullable: false),
                        CreatedOn = c.DateTimeOffset(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.UserRols",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(),
                        Active = c.Boolean(nullable: false),
                        CreatedBy = c.String(nullable: false),
                        CreatedOn = c.DateTimeOffset(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            AddColumn("dbo.Races", "State_Id", c => c.Int());
            AddColumn("dbo.Races", "Category_Id", c => c.Int());
            AddColumn("dbo.Users", "Rol_Id", c => c.Int());
            AddColumn("dbo.Users", "RaceCategory_Id", c => c.Int());
            AddForeignKey("dbo.Races", "State_Id", "dbo.RaceStates", "Id");
            AddForeignKey("dbo.Races", "Category_Id", "dbo.CarCategories", "Id");
            AddForeignKey("dbo.Users", "Rol_Id", "dbo.UserRols", "Id");
            AddForeignKey("dbo.Users", "RaceCategory_Id", "dbo.CarCategories", "Id");
            CreateIndex("dbo.Races", "State_Id");
            CreateIndex("dbo.Races", "Category_Id");
            CreateIndex("dbo.Users", "Rol_Id");
            CreateIndex("dbo.Users", "RaceCategory_Id");
        }
        
        public override void Down()
        {
            DropIndex("dbo.Users", new[] { "RaceCategory_Id" });
            DropIndex("dbo.Users", new[] { "Rol_Id" });
            DropIndex("dbo.Races", new[] { "Category_Id" });
            DropIndex("dbo.Races", new[] { "State_Id" });
            DropForeignKey("dbo.Users", "RaceCategory_Id", "dbo.CarCategories");
            DropForeignKey("dbo.Users", "Rol_Id", "dbo.UserRols");
            DropForeignKey("dbo.Races", "Category_Id", "dbo.CarCategories");
            DropForeignKey("dbo.Races", "State_Id", "dbo.RaceStates");
            DropColumn("dbo.Users", "RaceCategory_Id");
            DropColumn("dbo.Users", "Rol_Id");
            DropColumn("dbo.Races", "Category_Id");
            DropColumn("dbo.Races", "State_Id");
            DropTable("dbo.UserRols");
            DropTable("dbo.CarCategories");
            DropTable("dbo.RaceStates");
        }
    }
}
